#ifndef CHEETAH_GRAPHICS_PROGRAM_GLSL_H
#define CHEETAH_GRAPHICS_PROGRAM_GLSL_H

#include "cheetah/core.h"
#include <GL/glew.h>

namespace cheetah {
namespace graphics {
class Material;
class ShaderObject;
class ProgramGLSL {
 public:
  ProgramGLSL();
  virtual ~ProgramGLSL();
  bool Load(const char *vertex_shader, const char *fragment_shader);
  void Begin() const;
  void End() const;
  static void Disable();
  void AttachShader(const ShaderObject &shader) const;
  void DetachShader(const ShaderObject &shader) const;
  bool Link();	
  int GetUniformVar(const char *name) const {
    return glGetUniformLocation(program_id_, name);
  }
  bool is_valid() const { return 0 != program_id_; }
  bool is_linked() const { return is_linked_; }
  uint32 program_id() const { return program_id_; }
 private:
  void PrintLinkLog() const;
  bool CheckLinkLog();
 private:
  uint32 program_id_;
  bool is_linked_;
};

inline bool InvalidVar(const int var) { return var < 0; }

class Effect : public ProgramGLSL {
public:
  virtual ~Effect() { }
  virtual void SetMaterial(const Material &mat) const { }
};
} // graphics
} // cheetah

#endif // CHEETAH_GRAPHICS_PROGRAM_GLSL_H
